<!DOCTYPE HTML>
<html  xmlns:th="http://www.thymeleaf.org">
<head th:include="_meta :: header">
    <title>分配</title>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">

        <form class="layui-form form form-horizontal"  id="form-audio-allot" action="#" th:action="@{/admin/allot/PptAllotAllToWorker}" method="post">

           <div class="layui-form-label" ><label>分配制作人：</label></div>
            <div class="layui-input-inline">
            <select id="usernameList" name="name" >
                <option value="" text="请选择" class="downUsername">请选择</option>
                <option th:each="z:${usernameList}"  th:value="${z.value}" th:text="${z.value}" class="downUsername">${z.value}
                </option>
            </select>
            </div>

                 <input id="idsBus" th:value="${idsBus}" name="idsBus" hidden>
            <input id="statusCode" th:value="${statusCode}" name="statusCode" hidden>
            <input id="groupId" th:value="${groupId}" name="groupId" hidden>

            <button  class="layui-btn" id="subbtn" type="submit">
                <i class="layui-icon">&#xe605;</i> 确认分配</a>
            </button>

        </form>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->
<div th:replace="_footer :: footerjs">
</div>
<!--/_footer 作为公共模版分离出去-->
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;
        // 监听全选
        form.on('checkbox(checkall)', function(data){

            if(data.elem.checked){
                $('tbody input').prop('checked',true);
            }else{
                $('tbody input').prop('checked',false);
            }
            form.render('checkbox');
        });
        form.on('select(selectchange)', function(data){
            console.log(data.value); //得到被选中的值
            var pageNo = $('#pageNo');
            var Form = $('form')
            pageNo.val(1);
            Form.submit();
            form.render('select');
        });
        //日期时间范围选择
        laydate.render({

        });
        lay('.timeSpace').each(function(){
            laydate.render({
                elem: this
                ,type: 'datetime'
                ,range: true //或 range: '~' 来自定义分割字符
            });
        });
    });



    // 表单提交
    $(function(){
        var idsBus = $('input[id="idsBus"]').val();
        var statusCode=$('input[id="statusCode"]').val();
        var groupId=$('input[id="groupId"]').val();
        $("#form-audio-allot").validate({
            submitHandler:function(form) {
                var downUsername = $('#usernameList').val();
                console.log("down", downUsername)
                if (downUsername == '') {
                    layer.msg("您还未选择要分配的下属");
                    return false;
                } else {
                    $.lock()
                    $(form).ajaxSubmit({
                        type: 'POST',
                        url: "/admin/allot/PptAllotAllToWorker",
                        success: function (data) {
                            if (data.code == "1") {
                                selfmsg('分配成功!', 1, function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.location.reload();
                                    parent.layer.close(index);
                                });
                            } else {
                                selfmsg('分配失败!');
                                $.unlock()
                            }
                        },
                        error: function () {
                            selfmsg('分配异常!', 5);
                            $.unlock()
                        }
                    });
                }
            }
        });
        // }
    });


</script>
</body>
</html>